execute unless score #players temp matches -2147483648..2147483647 store result score #players temp if entity @a
execute unless score #team temp matches -2147483648..2147483647 run team leave @a
execute unless score #team temp matches -2147483648..2147483647 store result score #team temp run random value 0..1

execute if score #team temp matches 0 as @r[team=] at @s run function vs:system/hub/joined_blue
execute if score #team temp matches 1 as @r[team=] at @s run function vs:system/hub/joined_red

scoreboard players add #team temp 1
execute if score #team temp matches 2 run scoreboard players set #team temp 0

scoreboard players remove #players temp 1

execute if score #players temp matches 1.. run return run function vs:system/hub/random_team

scoreboard players reset #players temp
scoreboard players reset #team temp